﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// AdminNotice.xaml 的交互逻辑
    /// </summary>
    public partial class AdminNotice : Page
    {
        public AdminNotice()
        {
            InitializeComponent();
        }

        string strCon = Properties.Resources.strCON;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd1 = new SqlCommand("select * from admin where status=@st", con);
            cmd1.Parameters.Add("@st", SqlDbType.Int, 10).Value = 1;
            SqlDataAdapter read1 = new SqlDataAdapter(cmd1);
            DataSet dataset1 = new DataSet();
            read1.Fill(dataset1);
            DataTable dt1 = dataset1.Tables[0];
            DataRowCollection row1 = dt1.Rows;
            DataRow dataRow1 = row1[0];
            int tem = Convert.ToInt32(dataRow1["adminNumber"]);
            SqlCommand cmd = new SqlCommand("insert into notice (announce,noticepeo) values(@an,@no)", con);
            cmd.Parameters.Add("@an", SqlDbType.VarChar, 50).Value = text.Text;
            cmd.Parameters.Add("@no", SqlDbType.Int, 10).Value = tem;
            cmd.ExecuteNonQuery();
            con.Close();
            text.Text = "";
            MessageBox.Show("发布成功");
        }
    }
}
